﻿using System;
using System.Collections.Generic;
using System.Text;

namespace FunctionalCLR.Core.Functions.Maths {
    public class LogNode : OperatorNode {
        public LogNode()
            : base() {
            base.Precedence = 3;
            base.Value = "'";
        }

        public override object Accept(IVisitor visitor) {
            return visitor.Visit(this);
        }

        public override FuncNode GetReversedFunction(int index) {
            return new PowerNode();
        }

        public override object Evaluate() {
            double lr = Convert.ToDouble(Left.Evaluate());
            double rr = Convert.ToDouble(Right.Evaluate());

            return Math.Pow(lr, 1 / rr).ToString();
        }
    }
}
